﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public class EditorRepresentation : IUpdateable
    {
        public Actor Actor;
        public Vector3 Position
        {
            get { return Actor.Position; }
            set { Actor.Position = value; }
        }

        public Renderer Renderer;

        public EditorRepresentation(string model, Renderer Renderer)
        {
            this.Renderer = Renderer;

            Actor = new Actor(model);
            Actor.IsRepresentation = true;

            if (Engine.Editor)
            {
                Renderer.SubmitActor(Actor);
            }
        }
        public EditorRepresentation(string model)
        {            
            Actor = new Actor(model);
            Actor.IsRepresentation = true;            
        }

        public void HideRepresentation()
        {
            Renderer.RemoveActor(Actor);
        }
        public void ShowRepresentation()
        {
            Renderer.SubmitActor(Actor);
        }

        public virtual void Update()
        {
            Actor.Update();
        }

        public virtual void Draw()
        {
            Actor.Draw();
        }

        public virtual void SerializeData(SerializeData Data)
        {
            Data.AddData("Renderer.Name", this.Renderer.Name);
        }

        private string RendererName;
        public virtual void DeserializeData(SerializeData Data)
        {
            RendererName = Data.GetData<string>("Renderer.Name");
            Renderer = (Renderer)EngineSystem.GetRenderer(RendererName);

            if (Engine.Editor)
            {
                Renderer.SubmitActor(Actor);
            }
        }
    }
}
